e.height *= sy;
image = cairo_surface_map_to_image (surface, &e);
- gdk_gl_context_upload_texture (paint_context, image, e.width, e.height, target);
+ gdk_gl_context_upload_texture (paint_context,
+ cairo_image_surface_get_data (image),
+ e.width,
+ e.height,
+ cairo_image_surface_get_stride (image),
+ target);
cairo_surface_unmap_image (surface, image);
rect.height = height;
tmp = cairo_surface_map_to_image (surface, &rect);
- gdk_gl_context_upload_texture (context, tmp, rect.width, rect.height, target);
+ gdk_gl_context_upload_texture (context,
+ cairo_image_surface_get_data (tmp),
+ rect.width,
+ rect.height,
+ cairo_image_surface_get_stride (tmp),
+ target);
cairo_surface_unmap_image (surface, tmp);
}
void
gdk_gl_context_upload_texture (GdkGLContext *context,
- cairo_surface_t *image_surface,
+ const guchar *data,
int width,
int height,
+ int stride,
guint texture_target)
{
GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
(priv->use_es && (priv->gl_version >= 30 || priv->has_unpack_subimage)))
{
glPixelStorei (GL_UNPACK_ALIGNMENT, 4);
- glPixelStorei (GL_UNPACK_ROW_LENGTH, cairo_image_surface_get_stride (image_surface) / 4);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, stride / 4);
if (priv->use_es)
glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
- cairo_image_surface_get_data (image_surface));
+ data);
else
glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
- cairo_image_surface_get_data (image_surface));
+ data);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
}
else
{
- GLvoid *data = cairo_image_surface_get_data (image_surface);
- int stride = cairo_image_surface_get_stride (image_surface);
int i;
if (priv->use_es)
glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
for (i = 0; i < height; i++)
- glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, (unsigned char*) data + (i * stride));
+ glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_RGBA, GL_UNSIGNED_BYTE, data + (i * stride));
}
else
{
glTexImage2D (texture_target, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
for (i = 0; i < height; i++)
- glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, (unsigned char*) data + (i * stride));
+ glTexSubImage2D (texture_target, 0, 0, i, width, 1, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, data + (i * stride));
}
}
}